<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>BI Component - Top Banner</title>
    <link rel="Stylesheet" type="text/css" href="../theme/css/comp_banner.css" />
    <script type="text/JavaScript" src="../api/js/jquery-1.8.3.js"></script>
    <script type="text/JavaScript" src="../api/js/jquery-ui-1.9.2.custom.js"></script>
    <script type="text/javascript" src="../api/boi.js"></script>

    <!-- [REQUIRED] SCRIPT FOR INTEGRATION WITH BOI -->
    <script type="text/javascript">
        $(document).ready(function () {
             BOIData.list.getCatalog('TEST_BI_APP', 'JSON', 'ADMIN', function(data){
              if(parent.debugMode) BOI.log += BOILib.Util.log('XML Report Catalog Loaded for ' + dashboard + ' using ' + format);
              //var jsonObject = eval(data);

              BOI.context.variables = {};
              if( BOI.debugMode) BOI.log += BOILib.Util.log('Start Populating Context');

              BOI.context.reportCatalogJSON  = $.parseJSON(data);
              BOI.context.reportCatalogTree =  BOI.context.reportCatalogJSON;
              var count = 0;
              populateCatalog(BOI.context.reportCatalogJSON, count, "");
          });
        });

        function populateCatalog(data, count, parent_id)
        {
           $.each(data, function(i, item){
                var report = new BOILib.Report();
                report.role = item.role;
                report.id = item.nodeID; // check with asharaf
                report.url = item.url;
                report.tech_name = item.key; // check with asharaf
                report.type = item.type;
                report.label = item.title;
                report.parent_id = parent_id;
                BOI.context.reports[report.id] =  report ;
                count ++;

                spaces = "";
                for(i = 0; i<= count ; i++) spaces += "&nbsp;&nbsp;";
                $("#tree").append(spaces + report.label + "<BR>");

                if(item.children != undefined)
                {
                  if(item.children.length > 0 )
                  {
                    populateCatalog(item.children, count, report.id);
                  }
                }
           });
        }
    </script>
</head>

<body>
<div id="tree">

</div>
</body>
</html>